package anli;

import java.util.Random;

public class anli2 {
    public static void main(String[] args) {
System.out.println(creaCode(4));
    }

    public static String creaCode(int n) {
        //创建一个随机数
        Random r = new Random();
        //定义code字符串
        String code="";
        for (int i = 1; i <=n ; i++) {
            //创建3个类型
            int nextInt = r.nextInt(3);
            switch (nextInt){
                case 0:
                    /**随机1-10的数**/
                    code+=r.nextInt(10);
                    break;
                case 1:
                    /**随机小字母**/
                   char c1= (char) (r.nextInt(26) + 65);
                   code+=c1;
                    break;
                case 2:
                    /**随机大写字母**/
                    char c2=(char) (r.nextInt(25)+97);
                    code+=c2;
                    break;

            }

        }
        return code;

    }
}
